<template>
	<d2-container>
		<!-- 主体部分 -->
		<template>
			<!-- 表格上方的按钮 -->
			<div class="table-header">
				<el-button type="primary" @click="addPage()">新增规则</el-button>
			</div>

			<!-- 表格 -->
			<!-- 表格统一用 带边框、条纹间隔 的样式 -->
			<el-table :data="tableData" stripe border style="width: 100%">
				<el-table-column type="index" fixed label="序号" width="50" align="center"></el-table-column>
				
				<el-table-column prop="ruleCode" label="规则编码" width="120"></el-table-column>
				<el-table-column prop="ruleName" label="规则名称" width="180"></el-table-column>
				<el-table-column prop="ruleType" label="规则类型" width="120" align="center">
					<template slot-scope="scope">
						<!-- <el-tag v-if="scope.row.ruleType == 1">注册赠券</el-tag> -->
						<el-tag type="warning" v-if="scope.row.ruleType == 2">我请客赠券</el-tag>
					</template>
				</el-table-column>
				<el-table-column prop="bonusAmount" label="消费券面额(元)" width="130" align="center"></el-table-column>
				
				<el-table-column prop="quantityBonusPlan" label="计划发放数量(张)" width="130" align="center"></el-table-column>
				<el-table-column prop="quantityBonus" label="已发放数量(张)" width="130" align="center"></el-table-column>
				<el-table-column prop="quantityReceiveLimit" label="每人限领数量(张)" width="130" align="center"></el-table-column>
				<el-table-column prop="ruleDesc" label="备注" width="150"></el-table-column>
				
				<el-table-column prop="activityStatus" label="上下架" width="90" align="center">
					<template slot-scope="scope">
						<el-tag type="success" v-if="scope.row.activityStatus == 1">上架</el-tag>
						<el-tag type="info" v-if="scope.row.activityStatus == 0">已下架</el-tag>
					</template>
				</el-table-column>
				
				<el-table-column prop="status" label="状态" width="90" align="center">
					<template slot-scope="scope">
						<el-tag type="danger" v-if="scope.row.status == 0">未生效</el-tag>
						<el-tag type="success" v-if="scope.row.status == 1">生效中</el-tag>
						<el-tag type="info" v-if="scope.row.status == 2">已失效</el-tag>
					</template>
				</el-table-column>
				
				<el-table-column prop="activityBeginTime" label="生效时间" width="150" :formatter="forDateValid"></el-table-column>
				<el-table-column prop="activityEndTime" label="失效时间" width="150" :formatter="forDateInvalid"></el-table-column>
				<el-table-column prop="createTime" label="创建时间" width="150" :formatter="forDateCreate"></el-table-column>
				
				<el-table-column label="操作" fixed="right" width="280">
					<template slot-scope="scope">
						<el-button type="success" size="small" @click="updateStatus(scope.row, 1)" v-if="scope.row.status == 0">生效</el-button>
						<el-button type="danger" size="small" @click="updateStatus(scope.row, 2)" v-if="scope.row.status == 1">停止</el-button>
						
						<!-- 生效时才能上下架 -->
						<template v-if="scope.row.status == 1">
							<el-button type="success" size="small" @click="updateActivityStatus(scope.row, 1)" v-if="scope.row.activityStatus == 0">上架</el-button>
							<el-button type="info" size="small" @click="updateActivityStatus(scope.row, 0)" v-if="scope.row.activityStatus == 1">下架</el-button>
						</template>
						
						<!-- 未生效时才能编辑 -->
						<template v-if="scope.row.status == 0">
							<!-- <el-button type="primary" size="small" @click.native.prevent="updatePage(scope.row.id, scope.row.status)">编辑</el-button> -->
							<el-button type="info" plain size="small" @click.native.prevent="deleteRow(scope.row)">删除</el-button>
						</template>
						
						<el-button type="primary" plain size="small" @click.native.prevent="showPage(scope.row.id)">查看</el-button>
					</template>
				</el-table-column>
			</el-table>
		</template>

		<!-- 页脚部分 -->
		<template slot="footer">
			<div class="page">
				<el-pagination
					background
					:current-page="currentPage"
					:total="total"
					:page-sizes="[10, 20, 50, 100]"
					:page-size="pageSize"
					layout="total, sizes, prev, pager, next, jumper"
					@size-change="handleSizeChange"
					@current-change="handleCurrentChange"
				></el-pagination>
			</div>
		</template>

		<!-- 新增弹框 -->
		<template>
			<el-dialog title="新增消费券赠送规则" width="60%" :visible.sync="addDialog">
				<div class="form-area">
					<el-form ref="addForm" :model="addForm" :rules="addRules" label-width="120px" style="height:auto">
						<div class="form-title">
							<h3>新增规则</h3>
						</div>

						<el-row>
							<el-col :span="12">
								<el-form-item label="规则名称" prop="ruleName">
									<el-input type="text" v-model="addForm.ruleName" placeholder="请输入规则名称"></el-input>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="规则编码" prop="ruleCode">
									<el-input type="text" v-model="addForm.ruleCode" placeholder="请输入规则编码"></el-input>
								</el-form-item>
							</el-col>
						</el-row>

						<el-row>
							<el-col :span="12">
								<el-form-item label="规则类型" prop="ruleType">
									<el-select v-model="addForm.ruleType" placeholder="请选择类型" style="width:100%">
										<!-- <el-option value="1" label="会员注册赠券">会员注册赠券</el-option> -->
										<el-option value="2" label="我请客赠券">我请客赠券</el-option>
                                        -->
                                        <el-option value="2" label="我请客">我请客</el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="生效时间" prop="activityBeginTime">
									<el-date-picker v-model="addForm.activityBeginTime" type="date" placeholder="选择日期" align="right" style="width:100%">
									</el-date-picker>
								</el-form-item>
							</el-col>
						</el-row>

						<el-row>
							<el-col :span="24">
								<el-form-item label="备注" prop="ruleDesc">
									<el-input type="textarea" :rows="5" v-model="addForm.ruleDesc" placeholder="请输入备注"></el-input>
								</el-form-item>
							</el-col>
						</el-row>
						
						<div class="form-title">
							<h3>设置赠送规则</h3>
						</div>
						<el-row>
							<el-col :span="24">
								<el-form-item label="消费券商品" prop="productCouponId">
									<el-select v-model="addForm.productCouponId" placeholder="请选择消费券商品" @change="selectProductCoupon('addForm')" style="width:100%">
										<el-option v-for="productCoupon in productCouponList" :key="productCoupon.id" :label="`${productCoupon.productShowName}（${productCoupon.productName}）`" :value="productCoupon.id"></el-option>
									</el-select>
								</el-form-item>
							</el-col>
						</el-row>
						<el-row v-if="addForm.productCouponId">
							<el-col :span="12">
								<el-form-item label="消费券面额(元)" prop="productCouponDenomination">
									<el-input type="text" placeholder="请选择消费券商品" v-model="addForm.productCouponDenomination" disabled></el-input>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="可用库存" prop="addFormStock">
									<el-input type="text" placeholder="请选择消费券商品" v-model="addFormStock" disabled></el-input>
								</el-form-item>
							</el-col>
						</el-row>
						
						<!-- 我请客类型 -->
						<template v-if="addForm.ruleType == 2">
							<el-row>
								<el-col :span="12">
									<el-form-item label="活动参与人数" prop="participants">
										<el-input type="text" v-model.number="addForm.participants" placeholder="请输入活动最多参与人数"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item label="每人可请客数" prop="invitationQuantityLimit">
										<el-input type="text" v-model.number="addForm.invitationQuantityLimit" placeholder="请输入参与人每次请客人数"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>
								<el-col :span="12">
									<el-form-item label="受邀人可领(张)" prop="quantityReceiveLimit" label-width="150px">
										<el-input type="text" v-model.number="addForm.quantityReceiveLimit" placeholder="请输入受邀人可领数量" :disabled="couponType == 1"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item label="活动发放总数量">
										<el-input type="text" v-model="quantityBonusPlan" placeholder="计划发放总数量" readonly></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							
							<div class="form-title">
								<h3>设置奖励规则</h3>
							</div>
							<el-row>
								<el-col :span="12">
									<el-form-item label="请客人奖励商品" prop="productCouponIdToInviter">
										<el-select v-model="addForm.productCouponIdToInviter" placeholder="请选择消费券商品" style="width:100%" @change="selectRewardCoupon('addForm')">
											<el-option v-for="productCoupon in productCouponList2" :key="productCoupon.id" :label="`${productCoupon.productShowName}（${productCoupon.productName}）`" :value="productCoupon.id"></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item label="奖励数量" prop="quantityBonusToInviter">
										<el-input type="text" v-model="addForm.quantityBonusToInviter" placeholder="请输入奖励的数量"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row v-if="addForm.productCouponIdToInviter">
								<el-col :span="12">
									<el-form-item label="消费券库存">
										<el-input type="text" v-model="awardCouponStock" disabled></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item label="奖励总数量">
										<el-input type="text" v-model="awardCouponSummay" readonly></el-input>
									</el-form-item>
								</el-col>
							</el-row>
						</template>
						<!-- 会员注册赠券类型 -->
						<template v-if="addForm.ruleType == 1">
							<el-row>
								<el-col :span="12">
									<el-form-item label="计划发放总数量" prop="quantityBonusPlan">
										<el-input type="text" v-model.number="addForm.quantityBonusPlan" placeholder="计划发放总数量"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item label="每人限领(张)" prop="quantityReceiveLimit">
										<el-input type="text" v-model.number="addForm.quantityReceiveLimit" placeholder="请输入限领数量" :disabled="couponType == 1"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
						</template>
					</el-form>
				</div>

				<div class="dialog-footer" slot="footer">
					<el-button type="primary" @click="addSubmit('addForm')">保存新增</el-button>
					<el-button @click="addDialog =false">取 消</el-button>
				</div>
			</el-dialog>
		</template>

		<!-- 编辑弹框(暂停使用) -->
		<template>
			<el-dialog title="编辑消费券赠送规则" width="60%" :visible.sync="updateDialog">
				<div class="form-area">
					<el-form ref="updateForm" :model="updateForm" :rules="updateRules" label-width="120px" style="height:auto">
						<div class="form-title">
							<h3>编辑规则</h3>
						</div>
						
						<el-row>
							<el-col :span="12">
								<el-form-item label="规则名称" prop="ruleName">
									<el-input type="text" v-model="updateForm.ruleName" placeholder="请输入规则名称"></el-input>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="规则编码" prop="ruleCode">
									<el-input type="text" v-model="updateForm.ruleCode" placeholder="请输入规则编码"></el-input>
								</el-form-item>
							</el-col>
						</el-row>

						<el-row>
							<el-col :span="12">
								<el-form-item label="规则类型" prop="ruleType">
									<el-select v-model="updateForm.ruleType" placeholder="请选择" style="width:100%">
										<!-- <el-option value="1" label="会员注册赠券">会员注册赠券</el-option> -->
										<el-option value="2" label="我请客赠券">我请客赠券</el-option>
									</el-select>
								</el-form-item>
							</el-col>
							
							<el-col :span="12">
								<el-form-item label="状态" prop="status">
									<el-select v-model="updateForm.status" disabled style="width:100%">
										<el-option value="0" label="未生效">未生效</el-option>
										<el-option value="1" label="生效中">生效中</el-option>
										<el-option value="2" label="已失效">已失效</el-option>
									</el-select>
								</el-form-item>
							</el-col>
						</el-row>

						<el-row>
							<el-col :span="12">
								<el-form-item label="生效时间" prop="activityBeginTime">
									<el-date-picker v-model="updateForm.activityBeginTime" type="date" placeholder="选择日期时间" align="right" :picker-options="pickerOptions" style="width:100%">
									</el-date-picker>
								</el-form-item>
							</el-col>
						</el-row>

						<el-row>
							<el-col :span="24">
								<el-form-item label="备注" prop="ruleDesc">
									<el-input type="textarea" :rows="5" v-model="updateForm.ruleDesc" placeholder="请输入备注"></el-input>
								</el-form-item>
							</el-col>
						</el-row>

						<div class="form-title">
							<h3>设置赠送规则</h3>
						</div>
						<el-row>
							<el-col :span="24">
								<el-form-item label="消费券商品" prop="productCouponId">
									<el-input type="text" v-model="updateForm.productCouponName" disabled></el-input>
								</el-form-item>
							</el-col>
						</el-row>
						<el-row>
							<el-col :span="12">
								<el-form-item label="消费券面额(元)" prop="productCouponDenomination">
									<el-input type="text" v-model="updateForm.productCouponDenomination" disabled></el-input>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="可用库存" prop="updateFormStock">
									<el-input type="text" v-model="updateFormStock" disabled></el-input>
								</el-form-item>
							</el-col>
						</el-row>
						
						<!-- 我请客类型 -->
						<template v-if="updateForm.ruleType == 2">
							<el-row>
								<el-col :span="12">
									<el-form-item label="活动参与人数" prop="participants">
										<el-input type="text" v-model.number="updateForm.participants" placeholder="活动最多参与人数"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item label="每人可请客数" prop="invitationQuantityLimit">
										<el-input type="text" v-model.number="updateForm.invitationQuantityLimit" placeholder="请输入参与人每次请客人数"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>
								<el-col :span="12">
									<el-form-item label="受邀人可领(张)" prop="quantityReceiveLimit" label-width="150px">
										<el-input type="text" v-model.number="updateForm.quantityReceiveLimit" placeholder="请输入受邀人可领数量"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item label="活动发放总数量">
										<el-input type="text" v-model="quantityBonusPlan" placeholder="计划发放总数量" readonly></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							
							<div class="form-title">
								<h3>设置奖励规则</h3>
							</div>
							<el-row>
								<el-col :span="12">
									<el-form-item label="请客人奖励商品" prop="productCouponIdToInviter">
										<el-select v-model="updateForm.productCouponIdToInviter" placeholder="请选择消费券商品" style="width:100%" @change="selectRewardCoupon('updateForm')">
											<el-option v-for="productCoupon in productCouponList2" :key="productCoupon.id" :label="`${productCoupon.productShowName}（${productCoupon.productName}）`" :value="productCoupon.id"></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item label="奖励数量" prop="quantityBonusToInviter">
										<el-input type="text" v-model="updateForm.quantityBonusToInviter" placeholder="请输入奖励的数量"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>
								<el-col :span="12">
									<el-form-item label="消费券库存">
										<el-input type="text" v-model="awardCouponStock" disabled></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item label="奖励总数量">
										<el-input type="text" v-model="awardCouponSummay" readonly></el-input>
									</el-form-item>
								</el-col>
							</el-row>
						</template>
						
						<template v-if="updateForm.ruleType == 1">
							<el-row>
								<el-col :span="12">
									<el-form-item label="计划发放数量" prop="quantityBonusPlan">
										<el-input type="text" v-model.number="updateForm.quantityBonusPlan" placeholder="请输入计划发放数量"></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item label="每人限领(张)" prop="quantityReceiveLimit">
										<el-input type="text" v-model.number="updateForm.quantityReceiveLimit" placeholder="请输入限领数量"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
						</template>
						
						<!-- <el-row>
							<el-col :span="12">
								<el-form-item label="已发放数量" prop="quantityBonus">
									<el-input type="text" v-model="updateForm.quantityBonus" readonly></el-input>
								</el-form-item>
							</el-col>
						</el-row> -->

						<div class="form-title">
							<h3>系统信息</h3>
						</div>
						<el-row :gutter="20">
							<el-col :span="12">
								<el-form-item label="创建人">
									<el-input type="text" v-model="showForm.creator" readonly></el-input>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="创建时间">
									<el-input :value="forDate(showForm.createTime)" readonly></el-input>
								</el-form-item>
							</el-col>
						</el-row>

						<el-row :gutter="20">
							<el-col :span="12">
								<el-form-item label="修改人">
									<el-input type="text" v-model="showForm.reviser" readonly></el-input>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="修改时间">
									<el-input :value="forDate(showForm.reviseTime)" readonly></el-input>
									</el-date-picker>
								</el-form-item>
							</el-col>
						</el-row>
					</el-form>
				</div>

				<div class="dialog-footer" slot="footer">
					<el-button type="primary" @click="updateSubmit('updateForm')">保存修改</el-button>
					<el-button @click="updateDialog =false">取 消</el-button>
				</div>
			</el-dialog>
		</template>

		<!-- 查看弹框 -->
		<template>
			<el-dialog title="查看消费券赠送规则" width="60%" :visible.sync="showDialog">
				<div class="form-area">
					<el-form ref="showForm" :model="showForm" label-width="120px" style="height:auto">
						<div class="form-title">
							<h3>查看规则详情</h3>
						</div>
						<el-row>
							<el-col :span="12">
								<el-form-item label="规则名称" prop="ruleName">
									<el-input type="text" v-model="showForm.ruleName" readonly></el-input>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="规则编码" prop="ruleCode">
									<el-input type="text" v-model="showForm.ruleCode" readonly></el-input>
								</el-form-item>
							</el-col>
						</el-row>

						<el-row>
							<el-col :span="12">
								<el-form-item label="规则类型" prop="ruleType">
									<el-input :value="showForm.ruleType == 1 ? '会员注册赠券' : showForm.ruleType == 2 ? '我请客赠券' : '-'" readonly></el-input>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="状态" prop="status">
									<el-input :value="showForm.status == 1 ? '生效中' : showForm.status == 2 ? '已失效' : '未生效'" readonly></el-input>
								</el-form-item>
							</el-col>
						</el-row>
						<el-row>
							<el-col :span="12">
								<el-form-item label="生效时间" prop="activityBeginTime">
									<el-input :value="forDate(showForm.activityBeginTime)" readonly></el-input>
								</el-form-item>
							</el-col>
						</el-row>
						<el-row>
							<el-col :span="24">
								<el-form-item label="备注" prop="ruleDesc">
									<el-input type="textarea" :rows="5" v-model="showForm.ruleDesc" readonly></el-input>
								</el-form-item>
							</el-col>
						</el-row>
						
						<div class="form-title">
							<h3>赠送券规则</h3>
						</div>
						<el-row>
							<el-col :span="24">
								<el-form-item label="消费券商品" prop="productCouponId">
									<el-input type="text" v-model="showForm.productCouponName" readonly></el-input>
								</el-form-item>
							</el-col>
						</el-row>

						<el-row>
							<el-col :span="12">
								<el-form-item label="消费券面额(元)" prop="productCouponDenomination">
									<el-input type="text" v-model="showForm.productCouponDenomination" readonly></el-input>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="可用库存" prop="showFormStock">
									<el-input type="text" v-model="showFormStock" readonly></el-input>
								</el-form-item>
							</el-col>
						</el-row>
						
						<template v-if="showForm.ruleType == 2">
							<el-row>
								<el-col :span="12">
									<el-form-item label="活动参与人数" prop="participants">
										<el-input type="text" v-model="showForm.participants" readonly></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item label="每人可请客数" prop="invitationQuantityLimit">
										<el-input type="text" v-model="showForm.invitationQuantityLimit" readonly></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>
								<el-col :span="12">
									<el-form-item label="受邀人可领(张)" prop="quantityReceiveLimit" label-width="150px">
										<el-input type="text" v-model="showForm.quantityReceiveLimit" readonly></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							
							<el-row>
								<el-col :span="12">
									<el-form-item label="计划发放总数量" prop="quantityBonusPlan">
										<el-input type="text" v-model="showForm.quantityBonusPlan" readonly></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item label="已发放数量" prop="quantityBonus">
										<el-input type="text" v-model="showForm.quantityBonus" readonly></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							
							<div class="form-title">
								<h3>奖励规则</h3>
							</div>
							<el-row>
								<el-col :span="12">
									<el-form-item label="请客人奖励商品">
										<el-input type="text" v-model="showForm.productCouponToInviter" readonly></el-input>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item label="每次请客奖励数量" prop="quantityBonusToInviter" label-width="135px">
										<el-input type="text" v-model="showForm.quantityBonusToInviter" readonly></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>
								<el-col :span="12">
									<el-form-item label="可用库存">
										<el-input type="text" v-model="awardCouponStock" readonly></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item label="奖励总数量">
										<el-input type="text" v-model="awardCouponSummay" readonly></el-input>
									</el-form-item>
								</el-col>
							</el-row>
						</template>
						
						<template v-if="showForm.ruleType == 1">
							<el-row>
								<el-col :span="12">
									<el-form-item label="计划发放数量" prop="quantityBonusPlan">
										<el-input type="text" v-model.number="showForm.quantityBonusPlan" placeholder="请输入计划发放数量" readonly></el-input>
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item label="已发放数量" prop="quantityBonus">
										<el-input type="text" v-model="showForm.quantityBonus" readonly></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>
								<el-col :span="12">
									<el-form-item label="每人限领(张)" prop="quantityReceiveLimit">
										<el-input type="text" v-model.number="showForm.quantityReceiveLimit" placeholder="请输入限领数量" readonly></el-input>
									</el-form-item>
								</el-col>
							</el-row>
						</template>

						<div class="form-title">
							<h3>系统信息</h3>
						</div>
						<el-row :gutter="20">
							<el-col :span="12">
								<el-form-item label="创建人">
									<el-input type="text" v-model="showForm.creator" readonly></el-input>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="创建时间">
									<el-input :value="forDate(showForm.activityBeginTime)" readonly></el-input>
								</el-form-item>
							</el-col>
						</el-row>

						<el-row :gutter="20">
							<el-col :span="12">
								<el-form-item label="修改人">
									<el-input type="text" v-model="showForm.reviser" readonly></el-input>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="修改时间">
									<el-input :value="forDate(showForm.reviseTime)" readonly></el-input>
								</el-form-item>
							</el-col>
						</el-row>
					</el-form>
				</div>

				<div class="dialog-footer" slot="footer">
					<el-button @click="showDialog =false">关 闭</el-button>
				</div>
			</el-dialog>
		</template>
	</d2-container>
</template>

<script>
	import { findCouponBonusRuleListByPage, findCouponBonusRule, saveCouponBonusRule, deleteCouponBonusRule, updateStatus, updateActivityStatus } from '@api/activity/couponBonusRule'
	import { findUpProductCouponList, findAllProductCouponList } from '@api/coupon/productCoupon'
	import dayjs from 'dayjs'
	export default {
		name: 'activity-couponBonusRuleList',
		data() {
			return {
				tableData: [],
				currentPage: 1,
				pageSize: 10,
				total: 0,

				productCouponList: [], //发放用券列表
				showFormStock: '0',
				addFormStock: '0',
				updateFormStock: '0',
				couponType: 0, //券类型 1新人礼 2直播间叠加券
				productCouponList2: [], //奖励用券列表
				awardCouponStock: 0,

				showDialog: false,
				showForm: {
					ruleName: '',
					ruleCode: '',
					ruleType: '',
					status: '',
					activityBeginTime: '',
					productCouponId: '',
					productCouponName: '',
					productCouponDenomination: '0',
					bonusAmount: '',
					bonusCost: '',
					quantityBonusPlan: '',
					quantityBonus: '0',
					participants: '',
					quantityReceiveLimit: '',
					productCouponIdToInviter: '',
					quantityBonusToInviter: '',
					ruleDesc: '',
					creator: '',
					createTime: '',
					reviser: '',
					reviseTime: ''
				},

				addDialog: false,
				addForm: {
					ruleName: '',
					ruleCode: '',
					ruleType: '2',
					status: '0',
					activityBeginTime: '',
					productCouponId: '',
					productCouponName: '',
					productCouponDenomination: '0',
					bonusAmount: '',
					bonusCost: '',
					participants: '',
					invitationQuantityLimit: '',
					quantityReceiveLimit: '',
					quantityBonusPlan: '',
					quantityBonus: '0',
					productCouponIdToInviter: '',
					quantityBonusToInviter: '',
					ruleDesc: ''
				},
				addRules: {
					ruleName: [{ required: true, message: '请输入规则名称', trigger: 'blur' }, { min: 1, max: 32, message: '长度在 1 到 32 个字符', trigger: 'blur' }],
					ruleCode: [{ required: true, message: '请输入规则编码', trigger: 'blur' }, { min: 1, max: 32, message: '长度在 1 到 32 个字符', trigger: 'blur' }],
					ruleType: [{ required: true, message: '请选择规则类型', trigger: 'blur' }],
					activityBeginTime: [{ required: true, message: '请选择生效时间', trigger: 'blur' }],
					productCouponId: [{ required: true, message: '请选择消费券商品', trigger: 'blur' }],
					participants: [{ required: true, message: '请输入活动最多参与人数', trigger: 'blur' }, { type: 'number', message: '请填写数字' }],
					invitationQuantityLimit: [{ required: true, message: '请输入每次请客人数', trigger: 'blur' }, { type: 'number', message: '请填写数字' }],
					quantityReceiveLimit: [{ required: true, message: '请输入每人限领数量', trigger: 'blur' }, { type: 'number', message: '请填写数字' }],
					quantityBonusPlan: [{ required: true, message: '请输入计划发放总数量', trigger: 'blur' }, { type: 'number', message: '请填写数字' }],
					ruleDesc: [{ required: true, message: '请输入备注', trigger: 'blur' }, { min: 1, max: 64, message: '长度在 1 到 64 个字符', trigger: 'blur' }]
				},

				updateDialog: false,
				updateForm: {
					id: '',
					ruleName: '',
					ruleCode: '',
					ruleType: '1',
					status: '0',
					activityBeginTime: '',
					productCouponId: '',
					productCouponName: '',
					productCouponDenomination: '0',
					bonusAmount: '',
					bonusCost: '',
					participants: '',
					invitationQuantityLimit: '',
					quantityReceiveLimit: '',
					quantityBonusPlan: '',
					quantityBonus: '0',
					productCouponIdToInviter: '',
					quantityBonusToInviter: '',
					ruleDesc: '',
					// creator: '',
					// createTime: '',
					// reviser: '',
					// reviseTime: ''
				},
				updateRules: {
					ruleName: [{ required: true, message: '请输入规则名称', trigger: 'blur' }, { min: 1, max: 32, message: '长度在 1 到 32 个字符', trigger: 'blur' }],
					ruleCode: [{ required: true, message: '请输入规则编码', trigger: 'blur' }, { min: 1, max: 32, message: '长度在 1 到 32 个字符', trigger: 'blur' }],
					ruleType: [{ required: true, message: '请选择规则类型', trigger: 'blur' }],
					activityBeginTime: [{ required: true, message: '请选择生效时间', trigger: 'blur' }],
					productCouponId: [{ required: true, message: '请选择消费券商品', trigger: 'blur' }],
					participants: [{ required: true, message: '请输入活动最多参与人数', trigger: 'blur' }, { type: 'number', message: '请填写数字' }],
					invitationQuantityLimit: [{ required: true, message: '请输入每次请客人数', trigger: 'blur' }, { type: 'number', message: '请填写数字' }],
					quantityReceiveLimit: [{ required: true, message: '请输入每人限领数量', trigger: 'blur' }, { type: 'number', message: '请填写数字' }],
					quantityBonusPlan: [{ required: true, message: '请输入计划发放总数量', trigger: 'blur' }, { type: 'number', message: '请填写数字' }],
					ruleDesc: [{ required: true, message: '请输入备注', trigger: 'blur' }, { min: 1, max: 64, message: '长度在 1 到 64 个字符', trigger: 'blur' }]
				},
				pickerOptions: {
					shortcuts: [{
						text: '今天',
						onClick(picker) {
							picker.$emit('pick', new Date());
						}
					}, {
						text: '昨天',
						onClick(picker) {
							const date = new Date();
							date.setTime(date.getTime() - 3600 * 1000 * 24);
							picker.$emit('pick', date);
						}
					}, {
						text: '一周前',
						onClick(picker) {
							const date = new Date();
							date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
							picker.$emit('pick', date);
						}
					}]
				},
			}
		},
		computed: {
			quantityBonusPlan() { //计算券发放的总数量
				let num = 0;
				
				// 添加
				if(this.addDialog && this.addForm.participants && this.addForm.invitationQuantityLimit && this.addForm.quantityReceiveLimit) {
					num = parseFloat(this.addForm.participants) * parseFloat(this.addForm.invitationQuantityLimit) * parseFloat(this.addForm.quantityReceiveLimit);
				}
				// 修改
				if(this.updateDialog && this.updateForm.participants && this.updateForm.invitationQuantityLimit && this.updateForm.quantityReceiveLimit) {
					num = parseFloat(this.updateForm.participants) * parseFloat(this.updateForm.invitationQuantityLimit) * parseFloat(this.updateForm.quantityReceiveLimit);
				}
				// 查看
				if(this.showDialog && this.showForm.participants && this.showForm.invitationQuantityLimit && this.showForm.quantityReceiveLimit) {
					num = parseFloat(this.showForm.participants) * parseFloat(this.showForm.invitationQuantityLimit) * parseFloat(this.showForm.quantityReceiveLimit);
				}
				
				return num;
			},
			awardCouponSummay() { //计算奖励券的总数量
				let num = 0;
				if(this.addDialog && this.addForm.participants && this.addForm.invitationQuantityLimit && this.addForm.quantityBonusToInviter) {
					num = this.addForm.participants * this.addForm.invitationQuantityLimit * this.addForm.quantityBonusToInviter;
				}
				if(this.updateDialog && this.updateForm.participants && this.updateForm.invitationQuantityLimit && this.updateForm.quantityBonusToInviter) {
					num = this.updateForm.participants * this.updateForm.invitationQuantityLimit * this.updateForm.quantityBonusToInviter;
				}
				if(this.showDialog && this.showForm.participants && this.showForm.invitationQuantityLimit && this.showForm.quantityBonusToInviter) {
					num = this.showForm.participants * this.showForm.invitationQuantityLimit * this.showForm.quantityBonusToInviter;
				}
				return num;
			}
		},
		methods: {
			fetchData() {
				this.loading = true;
				findCouponBonusRuleListByPage({
					currentPage: this.currentPage,
					pageSize: this.pageSize
				})
					.then(res => {
						this.tableData = res.data.content;
						this.total = res.data.total;
						this.loading = false;
					})
					.catch(err => {
						console.log('err', err);
						this.loading = false;
					})
			},
			handleSizeChange(val) {
				this.pageSize = val;
				this.fetchData();
			},
			handleCurrentChange(val) {
				this.currentPage = val;
				this.fetchData();
			},
			
			resetPage() {
				this.currentPage = 1;
				this.pageSize = 10;
				this.total = 0;
			},
			submitForm(formName) {
				this.resetPage();
				this.fetchData();
			},
			resetForm(formName) {
				this.$refs[formName].resetFields();
				this.time = [];
				this.resetPage();
				this.fetchData();
			},
			
			forDateValid(row, column) {
				return row.activityBeginTime == null ? '' : dayjs(row.activityBeginTime).format('YYYY-MM-DD HH:mm:ss');
			},
			forDateInvalid(row, column) {
				return row.activityEndTime == null ? '' : dayjs(row.activityEndTime).format('YYYY-MM-DD HH:mm:ss');
			},
			forDateCreate(row, column) {
				return row.createTime == null ? '' : dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss');
			},
			forDate(val) {
				return val ? dayjs(val).format('YYYY-MM-DD HH:mm:ss') : '-';
			},
			
			showPage(id) {
				this.showDialog = true;
				this.showFormStock = '0';
				this.showForm = {
					ruleName: '',
					ruleCode: '',
					ruleType: '',
					status: '0',
					activityBeginTime: '',
					productCouponId: '',
					productCouponName: '',
					productCouponDenomination: '0',
					quantityReceiveLimit: '',
					bonusAmount: '',
					bonusCost: '',
					quantityBonusPlan: '',
					quantityBonus: '0',
					ruleDesc: '',
					creator: '',
					createTime: '',
					reviser: '',
					reviseTime: ''
				}
				this.getDetail(id, "showForm");
			},
			addPage() { //添加
				this.addDialog = true;
				this.addFormStock = '0';
				this.awardCouponStock = 0;
				this.addForm = {
					ruleName: '',
					ruleCode: '',
					ruleType: '2',
					status: '0',
					activityBeginTime: '',
					productCouponId: '',
					productCouponName: '',
					productCouponDenomination: '0',
					participants: '',
					bonusAmount: '',
					bonusCost: '',
					quantityReceiveLimit: '',
					quantityBonusPlan: '',
					quantityBonus: '0',
					productCouponIdToInviter: '',
					quantityBonusToInviter: '',
					ruleDesc: ''
				}
				
				this.getUpProductCouponList();
			},
			updatePage(id) { //编辑
				this.updateDialog = true;
				this.updateFormStock = '0';
				this.awardCouponStock = 0;
				this.getDetail(id, "updateForm");
			},
			
			getDetail(id, flag) {
				this.loading = true;
				findCouponBonusRule({
					ruleId: id,
				})
					.then(res => {
						if (flag == 'showForm') {
							this.showForm = res.data;
							this.showForm.ruleType = res.data.ruleType + '';
							this.showForm.status = res.data.status + '';
							
							this.showForm.participants = res.data.quantityBonusPlan / res.data.invitationQuantityLimit / res.data.quantityReceiveLimit;
							if(res.data.mytreatSubRuleVo != undefined) {
								this.showForm.productCouponIdToInviter = res.data.mytreatSubRuleVo.productCouponId;
								this.showForm.productCouponToInviter = res.data.mytreatSubRuleVo.productCouponName;
								this.showForm.quantityBonusToInviter = res.data.mytreatSubRuleVo.bonusAmount;
							}
						}
						if (flag == 'updateForm') {
							this.showForm = res.data;
							this.updateForm.id = res.data.id;
							this.updateForm.ruleName = res.data.ruleName;
							this.updateForm.ruleCode = res.data.ruleCode;
							this.updateForm.ruleType = res.data.ruleType + '';
							this.updateForm.status = res.data.status + '';
							this.updateForm.activityBeginTime = res.data.activityBeginTime;
							this.updateForm.productCouponId = res.data.productCouponId;
							this.updateForm.productCouponName = res.data.productCouponName;
							this.updateForm.productCouponDenomination = res.data.productCouponDenomination;
							this.updateForm.bonusAmount = res.data.bonusAmount;
							this.updateForm.bonusCost = res.data.bonusCost;
							this.updateForm.quantityReceiveLimit = res.data.quantityReceiveLimit;
							this.updateForm.invitationQuantityLimit = res.data.invitationQuantityLimit;
							this.updateForm.quantityBonusPlan = res.data.quantityBonusPlan;
							this.updateForm.quantityBonus = res.data.quantityBonus;
							this.updateForm.productCouponIdToInviter = res.data.productCouponIdToInviter;
							this.updateForm.quantityBonusToInviter = res.data.quantityBonusToInviter;
							this.updateForm.ruleDesc = res.data.ruleDesc;
							
							this.updateForm.participants = res.data.quantityBonusPlan / res.data.invitationQuantityLimit / res.data.quantityReceiveLimit;
						}
						
						this.getAllProductCouponList(flag);
						this.loading = false;
					})
					.catch(err => {
						console.log('err', err);
						this.loading = false;
					})
			},
			
			// 新增保存
			addSubmit(formName) {
				this.$refs[formName].validate(valid => {
					if (valid) {
						this.loading = true;
						
						if(this.addForm.ruleType ==2) { //我请客类型
							if (this.quantityBonusPlan > this.addFormStock) {
								this.$message({
									message: '计划发放数量不能大于券商品可用库存',
									type: 'warning'
								});
								return;
							}
							if (this.addForm.quantityReceiveLimit <= 0) {
								this.$message({
									message: '每人限领数量不能小于等于0',
									type: 'warning'
								});
								return;
							}
							if (this.addForm.quantityReceiveLimit > this.quantityBonusPlan) {
								this.$message({
									message: '每人限领数量不能大于计划发放数量',
									type: 'warning'
								});
								return;
							}
						}
						if(this.addForm.ruleType == 1) { //注册赠送券类型
							if (this.addForm.quantityBonusPlan > this.addFormStock) {
								this.$message({
									message: '计划发放数量不能大于券商品可用库存',
									type: 'warning'
								});
								return;
							}
							if (this.addForm.quantityReceiveLimit <= 0) {
								this.$message({
									message: '每人限领数量不能小于等于0',
									type: 'warning'
								});
								return;
							}
							if (this.addForm.quantityReceiveLimit > this.addForm.quantityBonusPlan) {
								this.$message({
									message: '每人限领数量不能大于计划发放数量',
									type: 'warning'
								});
								return;
							}
						}
						
						let params = {
							ruleName: this.addForm.ruleName,
							ruleCode: this.addForm.ruleCode,
							ruleType: this.addForm.ruleType,
							status: '0',
							activityBeginTime: this.addForm.activityBeginTime,
							productCouponId: this.addForm.productCouponId,
							productCouponName: this.addForm.productCouponName,
							productCouponDenomination: this.addForm.productCouponDenomination,
							bonusAmount: this.addForm.bonusAmount,
							bonusCost: this.addForm.bonusCost,
							quantityReceiveLimit: this.addForm.quantityReceiveLimit,
							invitationQuantityLimit: this.addForm.invitationQuantityLimit,
							quantityBonusPlan: this.addForm.ruleType == 2 ? this.quantityBonusPlan : this.addForm.quantityBonusPlan,
							quantityBonus: this.addForm.quantityBonus,
							productCouponIdToInviter: this.addForm.productCouponIdToInviter,
							quantityBonusToInviter: this.addForm.quantityBonusToInviter,
							ruleDesc: this.addForm.ruleDesc
						}
						saveCouponBonusRule(params)
							.then(res => {
								if (res.code == '000000') {
									this.$message({
										message: res.message,
										type: "success"
									});
									
									this.fetchData();
									this.addDialog = false;
									this.loading = false;
								} else {
									this.$message({
										message: res.message,
										type: 'error'
									});
									return;
								}
							})
							.catch(() => {
								console.log("err", err);
								this.loading = false;
							})
					}
				})
			},
			// 编辑保存
			updateSubmit(formName) {
				this.$refs[formName].validate(valid => {
					if (valid) {
						this.loading = true;
						
						if(this.updateForm.ruleType == 2) { //我请客类型
							if (this.quantityBonusPlan > this.updateFormStock) {
								this.$message({
									message: '计划发放数量不能大于券商品可用库存',
									type: 'warning'
								});
								return;
							}
							if (this.updateForm.quantityReceiveLimit <= 0) {
								this.$message({
									message: '每人限领数量不能小于等于0',
									type: 'warning'
								});
								return;
							}
							if (this.updateForm.quantityReceiveLimit > this.quantityBonusPlan) {
								this.$message({
									message: '每人限领数量不能大于计划发放数量',
									type: 'warning'
								});
								return;
							}
						}
						if(this.updateForm.ruleType == 1) { //注册赠送券类型
							if (this.updateForm.quantityBonusPlan > this.updateFormStock) {
								this.$message({
									message: '计划发放数量不能大于券商品可用库存',
									type: 'warning'
								});
								return;
							}
							if (this.updateForm.quantityReceiveLimit <= 0) {
								this.$message({
									message: '每人限领数量不能小于等于0',
									type: 'warning'
								});
								return;
							}
							if (this.updateForm.quantityReceiveLimit > this.updateForm.quantityBonusPlan) {
								this.$message({
									message: '每人限领数量不能大于计划发放数量',
									type: 'warning'
								});
								return;
							}
						}
						
						let params = {
							id: this.updateForm.id,
							ruleName: this.updateForm.ruleName,
							ruleCode: this.updateForm.ruleCode,
							ruleType: this.updateForm.ruleType,
							status: this.updateForm.status,
							activityBeginTime: this.updateForm.activityBeginTime,
							productCouponId: this.updateForm.productCouponId,
							productCouponName: this.updateForm.productCouponName,
							productCouponDenomination: this.updateForm.productCouponDenomination,
							bonusAmount: this.updateForm.bonusAmount,
							bonusCost: this.updateForm.bonusCost,
							quantityReceiveLimit: this.updateForm.quantityReceiveLimit,
							invitationQuantityLimit: this.updateForm.invitationQuantityLimit,
							quantityBonusPlan: this.updateForm.ruleType == 2 ? this.quantityBonusPlan : this.updateForm.quantityBonusPlan,
							quantityBonus: this.updateForm.quantityBonus,
							productCouponIdToInviter: this.updateForm.productCouponIdToInviter,
							quantityBonusToInviter: this.updateForm.quantityBonusToInviter,
							ruleDesc: this.updateForm.ruleDesc
						}
						saveCouponBonusRule(params)
							.then(res => {
								if (res.code == '000000') {
									this.$message({
										message: res.message,
										type: "success"
									});
									this.fetchData();
									this.updateDialog = false;
									this.loading = false;
								} else {
									this.$message({
										message: res.message,
										type: 'error'
									});
									return;
								}
							})
							.catch(() => {
								console.log("err", err);
								this.loading = false;
							})
					}
				})
			},
			// 更新状态
			updateStatus(row, status) {
				this.$confirm("确认" + (status == 1 ? '生效' : '停止') + ("【" + row.ruleName + "】？")).then(_ => {
					this.loading = true;
					updateStatus({
						ruleId: row.id,
						status: status
					})
						.then(res => {
							if (res.code == '000000') {
								this.$message({
									message: res.message,
									type: "success"
								});
								this.fetchData();
								this.loading = false;
							} else {
								this.$message({
									message: res.message,
									type: 'error'
								});
								return;
							}
						})
						.catch(err => {
							console.log("err", err);
							this.loading = false;
						});
				});
			},
			// 上下架
			updateActivityStatus(item, status) {
				updateActivityStatus({
					ruleId: item.id,
					activityStatus: status
				})
					.then(() => {
						this.$message.success(`${status ? '上架成功' : '下架成功'}`);
						this.fetchData();
					})
			},
			// 删除
			deleteRow(row) {
				this.$confirm('确认删除' + row.ruleName + '？').then(_ => {
					this.loading = true
					deleteCouponBonusRule({
							ruleId: row.id
						})
						.then(res => {
							if (res.code == '000000') {
								this.$message({
									message: res.message,
									type: 'success'
								})
								this.fetchData()
								this.loading = false
							} else {
								this.$message({
									message: res.message,
									type: 'error'
								})
							}
						})
						.catch(err => {
							console.log('err', err)
							this.loading = false
						})
				})
			},
			
			// 获取上架消费券商品
			getUpProductCouponList(flag) {
				this.productCouponList = [];
				this.productCouponList2 = [];
				
				findUpProductCouponList({})
					.then(res => {
						if (res.code == '000000') {
							let list = res.data
							list.forEach(item => {
								if(item.saleChannel == 2) {
									this.productCouponList.push(item);
								}
								if(item.couponType == 2) {
									this.productCouponList2.push(item);
								}
							})
							if (flag === 'showForm' || flag === 'updateForm') {
								this.selectProductCoupon(flag);
								this.selectRewardCoupon(flag);
							}
						} else {
							this.$message({
								message: '消费券商品加载失败，请重试!',
								type: 'error'
							});
						}
					})
					.catch(err => {
						console.log('err', err);
					})
			},
			// 获取所有消费券商品
			getAllProductCouponList(flag) {
				this.productCouponList = [];
				this.productCouponList2 = [];
				
				findAllProductCouponList({})
					.then(res => {
						if (res.code == '000000') {
							let list = res.data
							list.forEach(item => {
								this.productCouponList.push(item);
								
								if(item.couponType == 2) {
									this.productCouponList2.push(item);
								}
							});
							if (flag === 'showForm' || flag === 'updateForm') {
								this.selectProductCoupon(flag);
								this.selectRewardCoupon(flag);
							}
						} else {
							this.$message({
								message: '消费券商品加载失败，请重试!',
								type: 'error'
							});
						}
					})
					.catch(err => {
						console.log('err', err);
					})
			},
			// 选择消费券商品
			selectProductCoupon(flag) {
				for (let index in this.productCouponList) {
					if (flag == 'showForm') {
						if (this.productCouponList[index].id == this.showForm.productCouponId) {
							this.showForm.productCouponName = this.productCouponList[index].productShowName + '(' + this.productCouponList[index].productName + '）';
							this.couponType = this.productCouponList[index].couponType;
							this.showForm.productCouponDenomination = this.productCouponList[index].couponDenomination;
							this.showFormStock = this.productCouponList[index].stock;
							this.showForm.bonusAmount = this.productCouponList[index].couponDenomination;
							this.showForm.bonusCost = this.productCouponList[index].couponDenomination;
						}
					}
					if (flag == 'addForm') {
						if (this.productCouponList[index].id == this.addForm.productCouponId) {
							this.addForm.productCouponName = this.productCouponList[index].productShowName + '(' + this.productCouponList[index].productName + '）';
							this.addForm.productCouponDenomination = this.productCouponList[index].couponDenomination;
							this.couponType = this.productCouponList[index].couponType;
							this.addFormStock = this.productCouponList[index].stock;
							this.addForm.bonusAmount = this.productCouponList[index].couponDenomination;
							this.addForm.bonusCost = this.productCouponList[index].couponDenomination;
							
							if(this.couponType == 1) {
								this.addForm.quantityReceiveLimit = 1;
							}
						}
					}
					if (flag == 'updateForm') {
						if (this.productCouponList[index].id == this.updateForm.productCouponId) {
							this.updateForm.productCouponName = this.productCouponList[index].productShowName + '(' + this.productCouponList[index].productName + '）';
							this.couponType = this.productCouponList[index].couponType;
							this.updateForm.productCouponDenomination = this.productCouponList[index].couponDenomination;
							this.updateFormStock = this.productCouponList[index].stock;
							this.updateForm.bonusAmount = this.productCouponList[index].couponDenomination;
							this.updateForm.bonusCost = this.productCouponList[index].couponDenomination;
							
							if(this.couponType == 1) {
								this.updateForm.quantityReceiveLimit = 1;
							}
						}
					}
				}
			},
			selectRewardCoupon(flag) {
				for (let index in this.productCouponList2) {
					if (flag == 'showForm') {
						if (this.productCouponList2[index].id == this.showForm.productCouponIdToInviter) {
							this.showForm.rewardCouponName = this.productCouponList2[index].productShowName + '(' + this.productCouponList2[index].productName + '）';
							this.awardCouponStock = this.productCouponList2[index].stock;
						}
					}
					if (flag == 'addForm') {
						if (this.productCouponList2[index].id == this.addForm.productCouponIdToInviter) {
							this.awardCouponStock = this.productCouponList2[index].stock;
						}
					}
					if (flag == 'updateForm') {
						if (this.productCouponList2[index].id == this.updateForm.productCouponIdToInviter) {
							this.awardCouponStock = this.productCouponList2[index].stock;
						}
					}
				}
			},
		},
		mounted() {
			this.fetchData();
		},
	}
</script>

<style lang="scss" scoped>
	// 样式请务必加scoped
	.el-divider {
		::v-deep .el-divider__text {
			font-size: 16px;
			font-weight: bold;
		}
	}
</style>